package com.itheima.controller;

import com.itheima.domain.Enterprise;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/books")
public class BookController {

    @Value("${lesson}")
    private String lesson;

    @Value("${server.port}")
    private Integer port;

    @Value("${enterprise.subject[1]}")
    private String subject;

    @Autowired
    private Environment evc;

    @Autowired
    private Enterprise enterprise;

    @GetMapping("/{id}")
    public String getById(@PathVariable Integer id){
        System.out.println("springboot running ..."+id);
        System.out.println(lesson);
        System.out.println(port);
        System.out.println(subject);
        System.out.println("-------------------");
        System.out.println(evc.getProperty("lesson"));
        System.out.println(evc.getProperty("server.port"));
        System.out.println(evc.getProperty("enterprise.subject[2]"));
        System.out.println("--------------------");
        System.out.println(enterprise);
        return "hello,springboot";
    }
}
